package com.yz.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yz.entity.Section;
import com.yz.entity.dto.SectionDto;
import com.yz.service.SectionService;
import com.yz.util.Result;

@RestController
public class SectionController {
	@Autowired
	private SectionService sectionService;
	
	@RequestMapping("/getSecList")
	public Object getSecList(SectionDto sectionDto,Section section) {
		List<Section> list = sectionService.getSec(sectionDto);
		sectionDto.setPage(null);
		sectionDto.setLimit(null);
		List<Section> list2 = sectionService.getSec(sectionDto);
		return new Result(0,"",list2.size(),list);
	}
	
	@RequestMapping("/addSec")
	public Object addSec(Section section) {
		if(sectionService.addSec(section)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	@RequestMapping("/updateSec")
	public Object updateSec(Section section) {
		if(sectionService.updateSec(section)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	@RequestMapping("/delSec")
	public Object delSec(int seid) {
		if(sectionService.delSec(seid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
}
